grammar Simplest;

options { 
  output=AST; 
  ASTLabelType=CommonTree; 
}
tokens {
	DOC='doc';
	TITLE='title';
	SHIT='expr';
}

@header {package hero.antlr2;} 

@lexer::header{package hero.antlr2;}

prog:   stat+ ;
stat:   atom2=atom NEWLINE { System.out.println("atom2 value is " + $atom2.value); } ;
/*
  returns [int value] :   
*/
atom  returns [int value]
  @init {
    System.out.println("init");
  }
  @after {
    System.out.println("after");
  }
  :
    INT {$value = Integer.parseInt($INT.text);}
    |   ID { System.out.println($ID.text); $value = 10; }
    ;

ID  :   ('a'..'z'|'A'..'Z')+ ;
INT :   '0'..'9'+ ;
NEWLINE:'\r'? '\n' ;
WS  :   (' '|'\t')+ {skip();} ;

